/*
 * 显示隐藏图片
 * @param   id  div的id
 * @param   show | hide
 */
function showImg(id, act)
{
  if (act == 'show')
  {
    document.getElementById(id).style.visibility = 'visible';
  }
  else
  {
    document.getElementById(id).style.visibility = 'hidden';
  }
}

/*
 * 气泡式提示信息
 */
var Message = {
    bottom : 0,
    count : 0,
    elem : "popMsg",
    tilt : "popMsgTitle",
    cont : "popMsgContent",
    mvTimer : null,

    set : function(content, title){//设置提示的内容和标题
            content = content || '';
            title = title || '';
            document.getElementById(Message.cont).innerHTML = content;
            document.getElementById(Message.tilt).innerHTML = title;
        },
    show : function(){//显示提示框
      try
      {
        Message.controlSound('msgBeep');
        document.getElementById(Message.elem).style.visibility = "visible"
        document.getElementById(Message.elem).style.display = "block"

        Message.bottom  = 0 - parseInt(document.getElementById(Message.elem).offsetHeight);
        Message.mvTimer = window.setInterval("Message.move()", 10);

        document.getElementById(Message.elem).style.bottom = Message.bottom + "px";
      }
      catch (e)
      {
        alert(e);
      }
    },
    move : function(){//移动提示框
      try
      {
        if (Message.bottom == 0)
        {
          window.clearInterval(Message.mvTimer)
          Message.mvTimer = window.setInterval("Message.close()", 10000);
        }

        Message.bottom ++ ;
        document.getElementById(Message.elem).style.bottom = Message.bottom + "px";
      }
      catch (e)
      {
        alert(e);
      }
    },
    close : function(){//关闭提示框
      document.getElementById(Message.elem).style.visibility = 'hidden';
      document.getElementById(Message.elem).style.display = 'none';
      document.getElementById(Message.cont).innerHTML = '';
      if (Message.mvTimer) window.clearInterval(Message.mvTimer)
    },
    controlSound : function(_sndObj){//消息框响铃
      sndObj = document.getElementById(_sndObj);
      try
      {
        sndObj.Play();
      }
      catch (e) { }
    }
};

function $import(path,type,title){
  var s,i;
  if(type == "js"){
    var ss = document.getElementsByTagName("script");
    for(i =0;i < ss.length; i++)
    {
      if(ss[i].src && ss[i].src.indexOf(path) != -1)return ss[i];
    }
    s      = document.createElement("script");
    s.type = "text/javascript";
    s.src  =path;
  }
  else if(type == "css")
  {
    var ls = document.getElementsByTagName("link");
    for(i = 0; i < ls.length; i++)
    {
      if(ls[i].href && ls[i].href.indexOf(path)!=-1)return ls[i];
    }
    s          = document.createElement("link");
    s.rel      = "alternate stylesheet";
    s.type     = "text/css";
    s.href     = path;
    s.title    = title;
    s.disabled = false;
  }
  else return;
  var head = document.getElementsByTagName("head")[0];
  head.appendChild(s);
  return s;
}